package valutatore;

import java.util.ArrayList;
import java.util.HashMap;

public class Frame {
	private HashMap<Ident, Value> map = new HashMap<Ident, Value>();

	public Frame(ArrayList<Ident> params, ArrayList<Ident> locals, ArrayList<Value> args) {
		for(int i=0; i<params.size(); ++i)
			this.map.put(params.get(i), args.get(i));
		for(int i=0; i<locals.size(); ++i)
			this.map.put(locals.get(i), Nil.nil);
	}

	public Value getValue(Ident ident) {
		return map.get(ident);
	}
	
	public Value setValue(Ident ident, Value value) {
		map.put(ident, value);
		return value;
	}
	
	public boolean contains(Ident ident) {
		return map.containsKey(ident);
	}

	@Override
	public String toString() {
		return map.toString();
	}
}
